
#include <os/xcommand.h>

namespace os
{

    bool XCreateFile(const path& file)
    {
        if(!XCreateDirectory(file.parent_path()))
            return false;
        return CreateFile(file);
    }

    bool XCreateDirectory(const path& dir)
    {
        ::std::list<path> for_create;

        path root = Root(dir);
        path cur = dir;
        for(;;)
        if(Exists(cur))
            break;
        else if(cur==root)
            return false;
        else
            (for_create.emplace_front(cur),cur = cur.parent_path());

        for(const auto& d: for_create)
        if(!CreateDirectory(d))
            return false;

        return true;
    }

    


}//namespace os

